﻿//=====================================================
// Copyright © 2017-2018 xuxuzhaozhao
// All rights reserved
// GUID: 80b71e14-6087-4df0-ade9-2800319da949
// CLR版本: 4.0.30319.42000
// 新建项输入的名称: HeaderAppenderHandler
// 机器名称: WIN10-20170502F
// 注册组织名: 成都名门汇科技有限公司（谊诚科技）
// 命名空间名称: UnitTestingWebAPI.API.Core.MessageHandlers
// 文件名: HeaderAppenderHandler
// 当前系统时间: 2017/10/21 17:42:39
// 当前登录用户名: xuxuzhaozhao
//======================================================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace UnitTestingWebAPI.API.Core.MessageHandlers
{
    public class HeaderAppenderHandler : DelegatingHandler
    {
        protected override async Task<HttpResponseMessage> SendAsync(
                HttpRequestMessage request, CancellationToken cancellationToken)
        {
            HttpResponseMessage response = await base.SendAsync(request, cancellationToken);

            response.Headers.Add("X-WebAPI-Header", "Web API Unit testing in chsakell's blog.");
            response.Headers.Add("Content-Type", "application/json");
            return response;
        }
    }
}
